package self.hoy.demo.cloud.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import self.hoy.demo.cloud.MyShowContextBean;

/**
 * @author 三共小不
 * @date 2021/7/5
 */
@Configuration
@EnableConfigurationProperties
public class CommonContextAutoConfiguration {
    String client = "common";

    @Value("${testcontext.name:hello}")
    String name;

    @Bean
    @ConditionalOnMissingBean
    public MyShowContextBean getCommonContext() {
        return new MyShowContextBean(client+":"+name);
    }
}
